#ifndef _UTILEX_LOCKLIST_HPP_
#define _UTILEX_LOCKLIST_HPP_

#include <crt_util.h>

template <typename T> class CLockList : public CAutoLock
{
public:
    CLockList()
    {
        _list_init(&m_list);
        m_count = 0;
    }
    ~CLockList() { }

public:
    HRESULT push_back(T* pNode)
    {
        rc_error(pNode != NULL, E_FAIL);
        SYNC_OBJ(this);

        _list_insert(&m_list, &pNode->list, _list_begin(&m_list));

        return S_OK;
    }

    HRESULT is_empty()
    {
        SYNC_OBJ(this);
        HRESULT hr = S_OK;
        return hr;
    }
    HRESULT clear()
    {
        SYNC_OBJ(this);

        return S_OK;
    }
    HRESULT dump()
    {
        SYNC_OBJ(this);

        return S_OK;
    }
    UINT get_list_size() { return m_count; }

private:
    _list_s m_list;
    int m_count;
};

#endif
